home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / String.sig < prev    next >
Encoding:
Text File  |  1996-07-03  |  3.2 KB  |  90 lines  |  [TEXT/R*ch]

  1. (* String -- SML Standard Library *)
  2.  
  3. local 
  4.     type char = Char.char
  5. in
  6.     type string = string
  7.     val maxLen    : int
  8.     val size      : string -> int
  9.     val sub       : string * int -> char
  10.     val substring : string * int * int -> string
  11.     val extract   : string * int * int option -> string
  12.     val concat    : string list -> string
  13.     val ^         : string * string -> string
  14.     val str       : char -> string
  15.     val implode   : char list -> string 
  16.     val explode   : string -> char list
  17.  
  18.     val translate : (char -> string) -> string -> string
  19.     val tokens    : (char -> bool) -> string -> string list
  20.     val fields    : (char -> bool) -> string -> string list
  21.  
  22.     val compare   : string * string -> General.ordering
  23.     val collate   : (char * char -> ordering) -> string * string -> ordering
  24.  
  25.     val <  : string * string -> bool
  26.     val <= : string * string -> bool
  27.     val >  : string * string -> bool
  28.     val >= : string * string -> bool
  29. end
  30.  
  31. (* the type [string] is the type of string of characters.
  32.  
  33.    [maxLen] is the maximal number of characters in a string.
  34.  
  35.    [size s] is the number of characters in string s.
  36.  
  37.    [sub(s, i)] is the i'th character of s, counting from zero.  
  38.    Raises Subscript if i<0 or i>=size s.
  39.  
  40.    [substring(s, i, n)] is the string s[i..i+n-1].  Raises Subscript
  41.    if i<0 or n<0 or i+n>size s.  Equivalent to extract(s, i, SOME n).
  42.  
  43.    [extract (s, i, NONE)] is the string s[i..size s-1].
  44.    Raises Subscript if i<0 or i>size s. 
  45.  
  46.    [extract (s, i, SOME n)] is the string s[i..i+n-1].
  47.    Raises Subscript if i<0 or n<0 or i+n>size s. 
  48.  
  49.    [concat ss] is the concatenation of all the strings in ss.
  50.    Raises Size if the sum of their sizes is greater than maxLen.
  51.  
  52.    [s1 ^ s2] is the concatenation of strings s1 and s2.
  53.  
  54.    [str c] is the string of size one which contains the character c.
  55.  
  56.    [implode cs] is the string containing the characters in the list cs.
  57.    Equivalent to concat (List.map str cs).
  58.  
  59.    [explode s] is the list of characters in the string s.
  60.  
  61.    [translate f s] applies f to every character of s, from left to
  62.    right, and returns the concatenation of the results.  Equivalent to
  63.    String.concat(List.map f (explode s)).
  64.  
  65.    [tokens p s] returns the list of tokens in s, from left to right, 
  66.    where a token is a non-empty maximal substring of s not containing 
  67.    any delimiter, and a delimiter is a character satisfying p.
  68.  
  69.    [fields p s] returns the list of fields in s, from left to right, 
  70.    where a field is a (possibly empty) maximal substring of s not 
  71.    containing any delimiter, and a delimiter is a character satisfying p.
  72.  
  73.    Two tokens may be separated by more than one delimiter, whereas two
  74.    fields are separated by exactly one delimiter.  If the only delimiter 
  75.    is the character #"|", then
  76.        "abc||def" contains two tokens:   "abc" and "def"
  77.        "abc||def" contains three fields: "abc" and "" and "def"
  78.  
  79.    [compare (s1, s2)] does lexicographic comparison, using the
  80.    standard ordering Char.compare on the characters.  Returns LESS,
  81.    EQUAL, or GREATER, according as s1 is less than, equal to, or
  82.    greater than s2.
  83.  
  84.    [collate cmp (s1, s2)] performs lexicographic comparison, using the 
  85.    given ordering cmp on characters.  
  86.  
  87.    [<], [<=], [>], and [>=] compare strings lexicographically.
  88. *)
  89.  
  90.